Pretypeset:

The purpose of this is to

This is achieved as follows: Row/column counters, maxima, and queues are reset. The tab- and interlineskip is removed to make taking the constructed box apart easier. And the halign template is used to apply an appropriate action for each entry that updates the counters and queue.

The special |@| is used to store the original |@| except when diagrams are nested.

( @@=

@@pretypeset#1@MATRIX PRETYPESET@=@ @ =@ @ 8=@@=@ @=@
==@ @ ##!@&&@@@##!@#1@@@@ )

The first entry in each row is special; in particular it moves the entries from the columns of the previous row (if any) into the second-level queue:

( @@ @>@ @ <@ @ne @=@ @@@ )

The common part should first typeset the object. : Currently there is only the default format—an escape mechanism should be provided such that the full power of <object> is available.

Then it should add something setting | < | Xc|,| Yc| > | equivalent to this to the queue:

|"1, 1"| + | < | αX' - βY'|,| βX' + αY'| > |

with (α, β) the current direction and

| < | X'|,| Y'| > | = | < | X"col"|,| Y"row"| > | + | < |$\displaystyle {\textstyle\frac{1}{2}}$×W"col"|,|-$\displaystyle {\textstyle\frac{1}{2}}$×H"row"| > |

where | < | X"col"|,| Y"row"| > | is the upper left corner of the bounding box of the entry, | < | W"col"|,| H"row"| > | is the width and height of the bounding box. Furthermore the code should set the edge and extents of the curent object.

While typesetting the entry, -commands are "disabled" by redefining |@| to just `eat' its arguments, so they don't interfere...

( @@@ =

@@@=@ @=@ @@ix@=@

@@@@ne @ =@@norm @*@*##1##@@star##1 @

@@@star#1#2#3!@ @=#1#2@@x

@@@norm#1!@@ @=@ @@ @ #1@@x

@@@x@@ @ )

Finally the following ensures that the last row in the diagram is treated correctly: if the last entry was an empty row then we ignore the row entirely if the |@| switch is set just as we ignore |*|-entries above.

( @if@ @false

@@@@@ =@@@i @ @=ne @@ @@ne @ = @@ =@

@@@@i@ <@ )

: Allow non-default objects for particular entries.

Here is the encoding of the above computation.

( @@#1#2#3#4#5#6#7#8#9@##1##2##3##4@SETUP "#1,#3"@ @ =-##2@ =.5@ @ ##1 @ii= ##4@ii=.5@ii @ii##3 @@ @ii -@@ @ @@ @ii @@ @ =#5=#6=#7=#8=#9@#1,#3@ @ )